﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Models;

namespace Player.DengLu
{
    public partial class DLindex : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        //登录
        protected void btn_DengLu_Click(object sender, EventArgs e)
        {
            //获取输入内容
            string Usname = this.txt_UserName.Text.Trim();
            string Pwd = this.txt_Password.Text.Trim();
            //判断输入
            bool blname=true;
            bool blpwd=true;
            bool blCunZai = true;
            //提示
            //用户名判断
            if (Usname.Length==0)
            {
                blname = false;
                this.lbl_name.Text = "请输入用户名";
            }
            else
            {
                this.lbl_name.Text = "";
            }
            //密码判断
            if (Pwd.Length==0)
            {
                blpwd = false;
                this.lbl_pwd.Text = "请输入密码";
            }
            else
            {
                this.lbl_pwd.Text = "";
            }
            //判断用户是否存在
            List<Users> ls = BLL.UsersManage.SelePDCZUsers(Usname,Pwd);
            if (ls.Count==0)
            {
                blCunZai = false;
                if (blname==true && blpwd==true)
                {
                    this.lbl_dlts.Text = "帐号或密码错误";
                }
                else
                {
                    this.lbl_dlts.Text = "";
                }
            }
            else
            {
                this.lbl_dlts.Text = "";
            }
            if (blname==false || blpwd==false || blCunZai==false)
            {
                return;
            }
            else
            {
                //获取用户id
               string id = ls[0].Us_Id.ToString();
                //保存用户id
               Session["usid"] = id;
                //跳转页面
                string href = string.Format("../ShouYe/shouye.aspx");
                Response.Redirect(href);
            }

        }

    }
}